package com.naiterui.ehp.bp.utils.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.stereotype.Component;

/**
 * @author gaoliangliang
 * @date 2019-06-20 11:34
 * @since 1.0.0
 */
@Component
public class EventUtil implements ApplicationEventPublisherAware {

    private static ApplicationEventPublisher eventPublisher;

    @Override
    public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
        if (eventPublisher == null) {
            eventPublisher = applicationEventPublisher;
        }
    }

    /**
     * @description 发布事件
     */
    public static void publishEvent(BizEvent event) {
        eventPublisher.publishEvent(event);
    }
}
